import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';


void main()=>runApp(
    MaterialApp(
      home: Scaffold(
        body: MyApp(),
      ),
      theme: ThemeData(
        primarySwatch: Colors.yellow,
        textTheme: TextTheme(),
        buttonTheme: ButtonThemeData(buttonColor: Colors.yellow),
      ),
    )
);

class MyApp extends StatefulWidget {

  @override
  State<StatefulWidget> createState() {
    return _MyAppState();
  }

}

class _MyAppState extends State<MyApp> {

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: EdgeInsets.fromLTRB(0,MediaQuery.of(context).padding.top,0,0),
      child: ListView(
        children: <Widget>[
          Center(
            child: Image(
              image: AssetImage("images/avatar.png"),
              width: 100.0,
            ),
          ),
          //快捷的构造函数Image.asset用于从asset中加载、显示图片
          Center(
            child: Image.asset("images/avatar.png",
              width: 100.0,
            ),
          ),
          Center(
            child: Image(
              image: NetworkImage(
                  "https://img1.baidu.com/it/u=3435361414,3054623528&fm=253&fmt=auto&app=138&f=JPEG?w=224&h=322"),
              width: 100.0,
              height: 100.0,
            ),
          ),
          //快捷的构造函数Image.network用于从网络加载、显示图片
          Center(
            child: Image.network(
              "https://img1.baidu.com/it/u=3435361414,3054623528&fm=253&fmt=auto&app=138&f=JPEG?w=224&h=322",
              width: 100.0,
            ),
          ),
          Center(
            child: Image.network(
              "https://img1.baidu.com/it/u=3435361414,3054623528&fm=253&fmt=auto&app=138&f=JPEG?w=224&h=322",
              width: 100.0,
            ),
          ),
          Center(
            child: Image.network(
              "https://img1.baidu.com/it/u=3435361414,3054623528&fm=253&fmt=auto&app=138&f=JPEG?w=224&h=322",
              width: 100.0,
              height: 100.0,
              fit: BoxFit.fill,//会拉伸填充满显示空间，图片本身长宽比会发生变化，图片会变形
            ),
          ),
          Center(
            child: Image.network(
              "https://img1.baidu.com/it/u=3435361414,3054623528&fm=253&fmt=auto&app=138&f=JPEG?w=224&h=322",
              width: 100.0,
              height: 100.0,
              fit: BoxFit.cover,//会按图片的长宽比放大后居中填满显示空间，图片不会变形，超出显示空间部分会被剪裁
            ),
          ),
          Center(
            child: Image.network(
              "https://img1.baidu.com/it/u=3435361414,3054623528&fm=253&fmt=auto&app=138&f=JPEG?w=224&h=322",
              width: 100.0,
              height: 100.0,
              fit: BoxFit.contain,//这是图片的默认适应规则，图片会在保证图片本身长宽比不变的情况下缩放以适应当前显示空间，图片不会变形。
            ),
          ),
          Center(
            child: Image.network(
              "https://img1.baidu.com/it/u=3435361414,3054623528&fm=253&fmt=auto&app=138&f=JPEG?w=224&h=322",
              width: 100.0,
              height: 100.0,
              fit: BoxFit.fitWidth,//图片的宽度会缩放到显示空间的宽度，高度会按比例缩放，然后居中显示，图片不会变形，超出显示空间部分会被剪裁。
            ),
          ),
          Divider(height:MediaQuery.of(context).padding.top),
        ],
      ),
    );
  }

}







